/**
 * Created by 30947 on 2018/7/18.
 */
// script.js  


$(function () {
  char3()

})
// 统计分析图


function char3() {
  // let myChartdata
    var gender = function(res) {
                        var myChart = echarts.init(document.getElementById("char3"));
                        var option = {
                                color: ['#80FFA5', '#00DDFF'],
                                tooltip: {
                                    trigger: 'axis',
                                    axisPointer: {
                                    type: 'cross',
                                    label: {
                                        backgroundColor: '#6a7985'
                                    }
                                    }
                                },
                                legend: {
                                    data: ['实际数据', '预测数据'],
                                    textStyle: {
                                      color: '#fff'
                                    }
                                },
                                toolbox: {
                                    feature: {
                                    saveAsImage: {}
                                    }
                                },
                                grid: {
                                    left: '5%',
                                    right: '4%',
                                    // top:'3%',q
                                    bottom: '2%',
                                    containLabel: true
                                },
                                xAxis: [
                                    {
                                    type: 'category',
                                    boundaryGap: false,
                                    data:res.map(item => item.date),
                                    axisLabel: {
                                      show: true,
                                      textStyle: {
                                        color: '#fff'
                                      }
                                    },
                                    }
                                ],
                                yAxis: [
                                    {
                                    type: 'value',
                                    axisLabel: {
                                      show: true,
                                      textStyle: {
                                        color: '#fff'
                                      }
                                    },
                                    }
                                ],
                                series: [
                                    {
                                    name: '实际数据',
                                    type: 'bar',
                                    stack: 'Total',
                                    areaStyle: {},
                                    emphasis: {
                                        focus: 'series'
                                    },
                                    data:res.map(item => item.aqi_sj)
                                    },
                                    {
                                    name: '预测数据',
                                    type: 'bar',
                                    stack: 'Total',
                                    areaStyle: {},
                                    emphasis: {
                                        focus: 'series'
                                    },
                                    data:res.map(item => item.aqi_yc)
                                    },
                                ]
                                }; 
                        myChart.setOption(option);
    }    
                    $.ajax({
                        url:'/eval',
                        method:'POST',
                        data:{
                            sql:'select * from ads_yc_all;'
                        },

                        success: gender
                    });
                  }